package com.stefan.lession05;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

public class ButtonDemo02 extends JFrame {

    public ButtonDemo02(){
        Container container = this.getContentPane();

        // 单选框
        JRadioButton jRadioButton01 = new JRadioButton("jRadioButton01");
        JRadioButton jRadioButton02 = new JRadioButton("jRadioButton01");
        JRadioButton jRadioButton03 = new JRadioButton("jRadioButton01");

        // 由于单选框只能选择一个，分组，一个组中只能选择一个
        ButtonGroup buttonGroup = new ButtonGroup();
        buttonGroup.add(jRadioButton01);
        buttonGroup.add(jRadioButton02);
        buttonGroup.add(jRadioButton03);

        container.add(jRadioButton01,BorderLayout.CENTER);
        container.add(jRadioButton02,BorderLayout.NORTH);
        container.add(jRadioButton03,BorderLayout.SOUTH);

        this.setVisible(true);
        this.setSize(500,300);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new ButtonDemo02();
    }
}
